package com.pri.chat.adapter;

import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.luck.picture.lib.tools.ScreenUtils;
import com.netease.nim.uikit.net.SharedHelper;
import com.netease.nim.uikit.net.entity.WishListBean;
import com.pri.chat.R;
import com.pri.chat.activity.WishMsgActivity;
import com.pri.chat.utils.GlideUtil;
import com.pri.chat.utils.StringUtils;
import com.pri.chat.utils.TimeUtils;
import com.pri.chat.view.ImageViewPlus;
import com.vondear.rxtool.RxActivityTool;

import java.util.List;

/**
 * 描述：添加类的描述
 *
 * @author
 * @time 2020/4/28
 */
public class WishAllAdapter1 extends BaseQuickAdapter<WishListBean, BaseViewHolder> {
    private OnImageClickListener mOnImageClickListener;
    public void setOnImageClickListener( OnImageClickListener listener) {
        mOnImageClickListener = listener;
    }
    public interface OnImageClickListener {

        void onItemClick(View view, int c_pos, int f_pos);
    }
    public WishAllAdapter1(int layoutResId, @Nullable List<WishListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, WishListBean item) {

        helper.addOnClickListener(R.id.iv_logo);
        helper.setText(R.id.tv_wish_desc, Html.fromHtml((StringUtils.isEmpty(item.getBiaoqian()) ?"":"<font color='#A396F5'>"+item.getBiaoqian()+"</font> ")+item.getContent()));
        GlideUtil.getInstance().loadHeadImg(mContext,helper.getView(R.id.iv_logo),item.getHeadPic());

        ImageView item_image = helper.getView(R.id.item_image);
        int width = (ScreenUtils.getScreenWidth(mContext)-ScreenUtils.dip2px(mContext,30))/2;
        ViewGroup.LayoutParams params = item_image.getLayoutParams();
        params.height = width-20;
        item_image.setLayoutParams(params);
        GlideUtil.getInstance().loadHeadImg(mContext,item_image,item.getPicList());

        item_image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Bundle bundle = new Bundle();
                bundle.putParcelable("wish", item);
                bundle.putInt("position",helper.getAdapterPosition());
                RxActivityTool.skipActivityForResult((Activity) mContext, WishMsgActivity.class,bundle,1);
            }
        });
    }
}

